package collections;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListTest3 {
    public static void main(String[] args) {

        List<String> list1 = new ArrayList<String>();
        list1.add( "周勃" );
        list1.add( "卫青" );
        list1.add( "霍去病" );
        list1.add( "岳飞" );

        List<String> list2 = new ArrayList<String>();
        list2.add( "文天祥" );
        list2.add( "辛弃疾" );
        System.out.println( list1 );

//        list1.addAll( list2 );
//        System.out.println( list1 );
        list1.addAll( 3 ,list2 );
        System.out.println( list1 );

        for ( int i = 0, n = list1.size(); i < n; i++ ){
            String s = list1.get( i );
            System.out.println( s );
        }

        System.out.println( "-----------------------" );

        Iterator<String> t = list1.iterator();
        while ( t.hasNext() ){
            String x = t.next();
            System.out.println( x );
        }

        System.out.println( "-----------------------" );

        for ( String x : list1){
            System.out.println( x );
        }

    }
}
